FROM python:3.7-alpine3.12

ENV OJ_ENV production

ADD . /app
WORKDIR /app

HEALTHCHECK --interval=5s --retries=3 CMD python /app/deploy/health_check.py

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
    apk add --update --no-cache build-base nginx openssl curl unzip supervisor jpeg-dev zlib-dev postgresql-dev freetype-dev && \
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir -r /app/deploy/requirements.txt && \
    apk del build-base --purge

RUN curl -L https://github.com/QingdaoU/OnlineJudgeFE/releases/download/oj_2.7.2/dist.zip -o dist.zip && \
    unzip dist.zip && \
    rm dist.zip

ENTRYPOINT /app/deploy/entrypoint.sh
